// components/moduleTop/moduleTop.js
const app = getApp();
Component({
  properties: {

  },
  data: {
    radio: null,

    moduleSelect: null, //选中的模式

    styles: [{
      class: '白鱼入舟',
      code: [],
    }, {
      class: '黄金时代',
      code: [],
    }, {
      class: '万紫千红',
      code: [],
    }, {
      class: '紫气东来',
      code: [],
    }, {
      class: '碧海蓝天',
      code: [],
    }, {
      class: '素雅粉红',
      code: [],
    }, {
      class: '清幽之绿',
      code: [],
    }, {
      class: '清冰蓝郁',
      code: [],
    }],

    lightModule: [{
        module: '关闭',
        code: 0
      }, {
        module: '单色模式',
        code: 1
      },
      {
        module: '呼吸模式',
        code: 2
      },
      {
        module: '渐变模式',
        code: 3
      },
      {
        module: '爆闪模式',
        code: 4,
      },
      {
        module: '律动模式',
        code: 5,
      }
    ]

  },
  methods: {
    //风格修改
    onChange(e) {
      let val = e.detail;
      this.setData({
        radio: val
      })
      console.log(e);
    },
    //模式修改
    onModule(e) {
      let val = e.detail.value;
      let L = this.data.lightModule[val];
      this.setData({
        moduleSelect: L
      })
      app.globalData.code_4 = L.code || 1;
      app.writeBLE(2)
    },
    //亮度修改
    sliderChange(e) {
      wx.showToast({
        icon: 'none',
        title: `当前值：${e.detail}`,
      });
      app.globalData.code_5 = Number(e.detail) / 10 || 5;
      app.writeBLE(2)
    }
  }
})